#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
typedef struct SLTNode
{
	int data;
	struct SLTNode* next;
	struct SLTNode* before;
}SLT;
SLT* FindNode(SLT* node,int n)
{
	assert(node);
	SLT* cur = node;
	if (cur->data > n)
	{
		return node;
	}
	while (cur != NULL)
	{
		if ((cur->data < n && cur->next->data > n) || (cur->data < n && cur->next == NULL))
		{
			return cur;
		}
		cur = cur->next;
	}
	return NULL;
}

void AddData(SLT* cur,int x)
{
	
	assert(cur);
	SLT* newnode = (SLT*)malloc(sizeof(SLT));
	if (newnode == NULL)
	{
		perror("malloc fail");
		return;
	}
	newnode->data = x;
	if (cur->data > x)
	{
		newnode->before = NULL;
		newnode->next = cur;
		cur->before = newnode;
	}
	else
	{
		newnode->next = cur->next;
		newnode->before = cur;
		cur->next = newnode;
	}
}
void Destroy(SLT* node)
{
	SLT* cur = node;
	while (cur != NULL)
	{
		SLT* tmp = cur;
		cur = cur->next;
		free(tmp);
	}
}
void Print(SLT* node)
{
	SLT* cur = node;
	while (cur!=NULL)
	{
		printf("%d->", cur->data);
		cur = cur->next;
	}
}
void SLTPushBack(SLT** tail,int x)
{
	assert(tail);
	(*tail) = (SLT*)malloc(sizeof(SLT));
	(*tail)->data = x;
	(*tail)->next = (SLT*)malloc(sizeof(SLT));
	(*tail)->next->before = tail;
	(*tail) = (*tail)->next;
	(*tail)->next = NULL;
}
int main()
{
	int i = 0;
	SLT* node;
	SLT* tail = node;
	node->before = NULL;
	for (i = 0; i < 10; i++)
	{
		int x = 0;
		scanf("%d", &x);
		SLTPushBack(&tail, x);
		tail = NULL;
	}
	int n = 0;
	scanf("%d", &n);
	SLT* pv = FindNode(node,n);
	AddData(pv, n);

	Print(node);

	Destroy(node);
	tail = node = NULL;
	return 0;
}
